#pragma once
#include "frame.h"
#include "types.h"
#include "filevect.h"
#include "menu.h"

class CHexFrame : public CFrame
{
public:
	CHexFrame();

	void Clear(HDC hdc, COLORREF color);
	void DrawBorder(HDC hdc);
	void PrintLine(HDC hdc, int iLine, TCHAR* ucLineBuf, HBRUSH hbr);

	virtual void Draw(HDC hdc);
	virtual void OnCreate(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
	virtual void OnMouseMove(int xPos, int yPos);
	virtual void OnLButtonUp(int xPos, int yPos);
	virtual void OnRButtonUp(int xPos, int yPos);
	virtual void OnInitMenuPopUp(HMENU hMenu, LPARAM lParam);
	virtual void OnDrawItem(LPDRAWITEMSTRUCT lpmis);
	virtual void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpmis);
	// scroll
	virtual void OnVScroll(UINT nSBCode, UINT nPos);
	virtual void OnHScroll(UINT nSBCode, UINT nPos);
	// focus
	virtual void OnSetFocus();
	virtual void OnKillFocus();

	FileVector<unsigned char> *FileBuffer;
	int iByteSpace/*, iBytesPerLine*/;
	int iNumlines, iUpdateLine;
	int iOffsetLength, iCharSpace, iCharsPerLine, cBufferY;
	int iCurrentLine, iCurrentByte, iCurrentNibble;
	int iTextEntryMode;

	enum Colors
	{
		cc_dte,
		cc_changes,
		cc_highlight,
		cc_text_e,
		cc_text_o,
		cc_text,
		cc_background,
		cc_separator,
		cc_sel_back_val,
		cc_sel_back,
		cc_sel_text_val,
		cc_sel_text,
		cc_bookmark,
		cc_count
	};

	COLORREF m_colors[cc_count];

	int iMouseX, iMouseY;
	int iLBDownX, iLBDownY;
	bool bLButtonIsDown, bSelected, bReadOnly, bPartialOpen;
	int cCharXDim, cCharYDim;
	int iHorizontalScrollPos, iVerticalScrollPos;
	bool bTimerSet;
	int iEndOfSelection;

	HFONT hFont;
	CMenu m_Menu;
};
